* Basics
cls 
cscript
set matsize 11000

* Set working directory
cd "/Users/alikagalwala/Library/CloudStorage/Dropbox/Whitten_Kagalwala/TS/JOP/Acceptance/KW_Replication/WLL Bounds Example Replication"

* Load UK party support data
use "UK Parties.dta", clear

* Generate TS variable
egen date = fill(448 449 450)
tsset date
format date %tm 

* Estimate ADL(1,1) (Table 3, Appendix F, WLL Bounds-ADL(1,1))
reg mvilab l.mvilab  mgvldrsat l.mgvldrsat  meoi l.meoi  moppldrsat l.moppldrsat date
bgodfrey,lags(12)
// Note that constant and Breusch-Godfrey are different in the table because the column is taken from WLL AJPS paper,
// as mentioned in the note below the table and in the discussion around it. The values for this column ((Table 3, Appendix F, WLL Bounds-ADL(1,1))) ///
// are taken from Table 5 of Webb, Lebo, & Linn AJPS 2020.

* Weak exogeneity testing, discussion around Table 3
reg mvilab l.mvilab  mgvldrsat l.mgvldrsat  meoi l.meoi  moppldrsat l.moppldrsat date
predict eyt, resid
reg mgvldrsat l.mgvldrsat  meoi l.meoi  moppldrsat l.moppldrsat date
predict ex1, resid
reg  eyt mgvldrsat ex1

reg  meoi mgvldrsat l.mgvldrsat  l.meoi  moppldrsat l.moppldrsat date
predict ex2, resid
reg  eyt meoi ex2

reg   moppldrsat mgvldrsat l.mgvldrsat  l.meoi   meoi l.moppldrsat date
predict ex3, resid
reg  eyt moppldrsat ex3

* Dickey-Fuller tests, discussion around Table 3
dfuller mvilab
dfuller mgvldrsat 
dfuller meoi
dfuller moppldrsat

* Estimate ADL(2,2) (Table 3, Appendix F, General-ADL(2,2) & WLL Bounds-ADL(2,2))
reg mvilab l.mvilab l2.mvilab mgvldrsat l.mgvldrsat l2.mgvldrsat meoi l.meoi l2.meoi moppldrsat l.moppldrsat l2.moppldrsat date 
bgodfrey,lags(12)

* Weak exogeneity testing, discussion around Table 3, Appendix F
reg mvilab l.mvilab l2.mvilab mgvldrsat l.mgvldrsat l2.mgvldrsat meoi l.meoi l2.meoi moppldrsat l.moppldrsat l2.moppldrsat date 
predict ey2t, resid
reg mgvldrsat l.mgvldrsat l2.mgvldrsat meoi l.meoi l2.meoi moppldrsat l.moppldrsat l2.moppldrsat date
predict ex12, resid
reg  ey2t mgvldrsat ex12

reg  meoi l.mgvldrsat l2.mgvldrsat l.meoi l2.meoi moppldrsat l.moppldrsat l2.moppldrsat date
predict ex22, resid
reg  ey2t meoi ex22

reg   moppldrsat l.mgvldrsat l2.mgvldrsat meoi l.meoi l2.meoi  l.moppldrsat l2.moppldrsat date
predict ex33, resid
reg  ey2t moppldrsat ex33

* Long-Run Multipliers for General-ADL(2,2) & WLL Bounds-ADL(2,2) (Table 3, Appendix F)
nlcom (_b[mgvldrsat] + _b[L1.mgvldrsat] + _b[L2.mgvldrsat])/(1 - _b[L1.mvilab] - _b[L2.mvilab]), df(141) 
nlcom (_b[meoi] + _b[L1.meoi] + _b[L2.meoi])/(1 - _b[L1.mvilab] - _b[L2.mvilab]), df(141) 
nlcom (_b[moppldrsat] + _b[L1.moppldrsat] + _b[L2.moppldrsat])/(1 - _b[L1.mvilab] - _b[L2.mvilab]), df(141)
// Significance for the long-run multipliers for General-ADL(2,2) are taken from the above tests.
// Significance the long-run multipliers for for WLL Bounds-ADL(2,2) are assessed as follows:
// If the absolute value of the t-stastic:
//	|t| < 1.01, not significant
// 1.01 < |t|, < 3.65 inconclusive
// |t| > 3.65, significant
// These bounds are taken from Table 2, T = 150, a = 0.05, and k=3 (WLL AJPS 2020)


